import 'package:flutter/material.dart';
import 'package:url_launcher/url_launcher.dart';

class LeaderPage extends StatelessWidget {
  final String leaderImage;//图片
  final String leaderPhone;//电话

  LeaderPage({Key key, this.leaderImage, this.leaderPhone}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      child: InkWell(//点击组件
        child: Image.network(leaderImage),
        onTap: _launchURL,//点击的方法
      ),
    );
  }

  void _launchURL() async {
    print('手机号:'+leaderPhone);
    String url = 'tel:' + leaderPhone;//打电话
    if (await canLaunch(url)) {//判断url是否可用
      await launch(url);//调用url
    } else {
      throw '不能访问$url';
    }
  }
}
